package com.mystnihon.tdroid.loader;

import java.io.IOException;

import android.content.Context;
import android.util.Log;
import ca.benow.transmission.TransmissionClient;

import com.mystnihon.tdroid.config.Config;

public class RemoveTorrentLoader extends AbstractAsyncLoader<Void> {

	private static final String TAG = RemoveTorrentLoader.class.getSimpleName();
	private TransmissionClient mclient;
	Object[] mIds;
	boolean mDeleteLocalData;

	public RemoveTorrentLoader(TransmissionClient client, boolean deleteLocalData, Object... ids) {
		mclient = client;
		mDeleteLocalData = deleteLocalData;
		mIds = ids;
	}

	@Override
	protected boolean doLoad(Context context) {
		try {
			mclient.removeTorrents(mIds, mDeleteLocalData);
			if (Config.DEBUG_MODE_ENABLED)
				Log.d(TAG, "Loading return true");
			return true;
		} catch (IOException e) {
			if (Config.ERROR_MODE_ENABLED)
				Log.e(TAG, "Erreur", e);
		}
		return false;
	}

}
